package com.css.fxfzaqbz.modules.assess.service.impl;

import com.css.fxfzaqbz.constants.YNEnum;
import com.css.fxfzaqbz.modules.assess.entity.BigCasualtiesEntity;
import com.css.fxfzaqbz.modules.assess.repository.BigCasualtiesRepository;
import com.css.fxfzaqbz.modules.assess.repository.CasualtiesRepository;
import com.css.fxfzaqbz.modules.assess.service.BigCasualtiesService;
import com.css.fxfzaqbz.modules.data.entity.ImportantActivity;
import com.css.fxfzaqbz.modules.data.service.ImportantActivityService;
import com.css.fxfzaqbz.util.PlatformDateUtils;
import com.css.fxfzaqbz.util.PlatformSessionUtils;
import com.css.fxfzaqbz.util.UUIDGenerator;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * @author y1fan
 * @create 2022-09-20 9:29
 */
@Service
public class BigCasualtiesServiceImpl implements BigCasualtiesService {


    @Resource
    private BigCasualtiesRepository bigCasualtiesRepository;
    @Resource
    private ImportantActivityService importantActivityService;
    @Resource
    private CasualtiesRepository casualtiesRepository;


    @Override
    public void saveTask(ImportantActivity importantActivity1) {
        BigCasualtiesEntity casualtiesEntity = bigCasualtiesRepository.getBigCasualtiesByActiveId(importantActivity1.getIaId());
        if (casualtiesEntity == null) {
            BigCasualtiesEntity bigCasualtiesEntity1 = new BigCasualtiesEntity();
            bigCasualtiesEntity1.setBcId(UUIDGenerator.getUUID());
            bigCasualtiesEntity1.setContent("伤亡及需紧急安置人员评估");
            bigCasualtiesEntity1.setBcStatus(YNEnum.N.toString());
            bigCasualtiesEntity1.setBcActiveId(importantActivity1.getIaId());
            bigCasualtiesEntity1.setBcDelFlag(YNEnum.N.toString());
            bigCasualtiesEntity1.setBcCreateTime(PlatformDateUtils.getCurrentTimestamp());
            bigCasualtiesEntity1.setBcCreateUser(PlatformSessionUtils.getUserId());
            bigCasualtiesEntity1.setBcOpinion(importantActivity1.getIaOpinion());
            bigCasualtiesRepository.saveCasualties(bigCasualtiesEntity1);
        }

    }

    @Override
    public void upStatus(String id) {
        bigCasualtiesRepository.upStatus(id);

    }
}
